//=================================================
// begin of java script with objects definitions and globals
//=================================================

function rhObject(p_is_assembly, p_name, p_original_name, p_attributes,
	p_markup_names, p_material_names)
{
	this.is_assembly = p_is_assembly;
	this.name = p_name;
	this.original_name = p_original_name;
	this.attributes = p_attributes;
	this.markup_names = p_markup_names;
	this.material_names = p_material_names;
}

//=================================================

function rhPart(p_name, p_count, p_child_ids)
{
	this.name = p_name;
	this.count = p_count;
	this.child_ids = p_child_ids;
}

//=================================================

function rhCamera(p_default, p_private, p_name, p_original_name,
	p_org, p_target, p_up, p_ortho, p_fov, p_zoom,
	p_near, p_far, p_aspect, p_binding)
{
	this.is_default = p_default;
	this.is_private = p_private;
	this.name = p_name;
	this.original_name = p_original_name;
	this.org = p_org;
	this.target = p_target;
	this.up = p_up;
// additional parameters
	this.is_ortho = p_ortho;	// int 0|1
	this.fov = p_fov;			// float (degrees)
	this.zoom = p_zoom;			// float (scale factor for ortho projection)
	this.near = p_near;			// near clipplane
	this.far = p_far;			// far clipplane
	this.aspect = p_aspect;		// float w/h
	this.binding = p_binding;	// {fiminfl, fimaxfl, fihorizontalfl, fiverticalfl, or fiabsolutefl}
}

//=================================================

function rhBOM(p_object_id, p_name, p_count, p_child_ids)
{
	this.object_id = p_object_id;
	this.name = p_name;
	this.count = p_count;
	this.child_ids = p_child_ids;
}

//=================================================

function rhRange(p_name, p_camera_id, p_start, p_end, p_fps,
	p_speed, p_delay, p_repeat, p_rev)
{
	this.name = p_name;
	this.camera_id = p_camera_id;
	this.start = p_start;
	this.end = p_end;
	this.fps = p_fps;
	this.speed = p_speed;
	this.delay = p_delay;
	this.repeat = p_repeat;
	this.reversed = p_rev;
}

//=================================================

function rhView(p_is_step, p_name, p_desc, p_keywords, p_object_id,
	p_camera_id, p_object_names, p_ranges_ids, p_flyto_time, p_render_mode)
{
	this.is_step = p_is_step;
	this.name = p_name;
	this.description = p_desc;
	this.keywords = p_keywords;
	this.object_id = p_object_id;
	this.camera_id = p_camera_id;
	this.object_names = p_object_names;
	this.step_ids = p_ranges_ids;
	this.flyto_time = p_flyto_time;
	this.render_mode = p_render_mode;
}

//=================================================

function rhLayer(p_name, p_desc, p_object_names)
{
	this.name = p_name;
	this.description = p_desc;
	this.object_names = p_object_names;
}

//=================================================

function rhMVGroup(p_is_steps, p_name, p_mv_ids)
{
	this.is_steps = p_is_steps;
	this.name = p_name;
	this.mviews_ids = p_mv_ids;
}

//=================================================
// general holder of meta-data of one model

function rhAnnotationMetadata()
{
	this.rootAssembly = 0;									//workaround for Abbott parts in templates
	this.firstAssembly = -1;
	this.activeRange = -1;
	this.objects = new Array();
	this.objectsAssoc = new Array();
	this.parts = new Array();
	this.cameras = new Array();
	this.boms = new Array();
	this.ranges = new Array();
	this.views = new Array();
	this.layers = new Array();
	this.billboards = new Array();
	this.pointsets = new Array();
	this.mvgroups = new Array();
	this.renameInformation = new Array();					//direct mapping of u3d->original names
	this.renameInformationReverse = new Array();			//single value or array (check type!) original->u3d names
	this.materialRenameInformation = new Array();			//direct mapping of clone_material->original_material names or undefined if material was not renamed
	this.materialRenameInformationReverse = new Array();	//array of original->clone material names or undefined if material was not renamed

//=================================================
// methods for manipulate

	this.addObject = function(p_is_assembly, p_name, p_original_name,
		p_attributes, p_markup_names, p_material_names)
	{
		this.objects.push(new rhObject(p_is_assembly, p_name,
			p_original_name, p_attributes, p_markup_names,
			p_material_names) );
		this.objectsAssoc[p_name] = this.objects.length -1;
	}
	this.addPart = function(p_name, p_count, p_child_ids)
	{
		this.parts.push(new rhPart(p_name, p_count, p_child_ids) );
	}
	this.addCamera = function(p_default, p_private, p_name,
		p_original_name, p_org, p_target, p_up,
		p_ortho, p_fov, p_zoom, p_aspect, p_binding)
	{
		this.cameras.push(new rhCamera(p_default, p_private, p_name,
			p_original_name, p_org, p_target, p_up, p_ortho, p_fov,
			p_zoom, p_aspect, p_binding) );
	}
	this.addBOM = function(p_object_id, p_name, p_count, p_child_ids)
	{
		this.boms.push(new rhBOM(p_object_id, p_name, p_count, p_child_ids) );
	}
	this.addRange = function(p_name, p_camera_id, p_start, p_end, p_fps,
		p_speed, p_delay, p_repeat, p_rev)
	{
		this.ranges.push(new rhRange(p_name, p_camera_id, p_start, p_end, p_fps,
			p_speed, p_delay, p_repeat, p_rev) );
	}
	this.addView = function(p_is_step, p_name, p_desc, p_keywords,
		p_object_id, p_camera_id, p_object_names, p_ranges_ids,
		p_flyto_time, p_render_mode)
	{
		this.views.push(new rhView(p_is_step, p_name, p_desc, p_keywords,
			p_object_id, p_camera_id, p_object_names, p_ranges_ids,
			p_flyto_time, p_render_mode) );
	}
	this.addLayer = function(p_name, p_desc, p_obj_names)
	{
		this.layers.push(new rhLayer(p_name, p_desc, p_obj_names) );
	}
	this.addSprite = function(name)
	{
		this.billboards.push(name);
	}
	this.addPointSet = function(name)
	{
		this.pointsets[name] = 1;
	}
	this.addRename = function(u3d_name, original_name)
	{
		this.renameInformation[u3d_name] = original_name;
	}
	this.addRenameReverse = function(original_name, u3d_name)
	{
		if (this.renameInformationReverse[original_name] == undefined)
		{
			this.renameInformationReverse[original_name] = u3d_name;
		}
		else if (typeof(this.renameInformationReverse[original_name]) != "Array")
		{
			var value = this.renameInformationReverse[original_name];
			this.renameInformationReverse[original_name] = new Array();
			this.renameInformationReverse[original_name].push(value);
			this.renameInformationReverse[original_name].push(u3d_name);
		}
		else
		{
			this.renameInformationReverse[original_name].push(u3d_name);
		}
	}
	this.addMtlClones = function(original_name, clones_array)
	{
		if (!clones_array.length)
			return;
		this.materialRenameInformationReverse[original_name] = clones_array;
	}
	this.addMtlOriginal = function(clone_name, original_name)
	{
		this.materialRenameInformation[clone_name] = original_name;
	}
	this.addMVGroup = function(p_is_steps, p_name, p_mv_ids)
	{
		this.mvgroups.push(new rhMVGroup(p_is_steps, p_name, p_mv_ids) );
	}
}

//=================================================
// global arrays

var default_steps_hidden_initial_position = "steps_hidden_sequence_workaround";
if (typeof(rhAnnotationMetadataArray) == "undefined")
{
	var rhAnnotationMetadataArray = new Array();
}

//=================================================
// end of java script with objects definitions and globals
//=================================================
